/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-17 15:33:27
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-17 15:36:22
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/controller/door_controller.dart';
import 'package:get/get.dart';

class DoorDetailMenu extends StatelessWidget {
  const DoorDetailMenu({Key key, this.currentIndex, this.onChange})
      : super(key: key);
  final int currentIndex;
  final ValueChanged<int> onChange;

  @override
  Widget build(BuildContext context) => GetBuilder<DoorController>(
        builder: (_controller) => Container(
          height: 50,
          child: ListView.builder(
            scrollDirection: Axis.horizontal,
            itemCount: _controller.menus.length,
            itemBuilder: (context, index) => GestureDetector(
              onTap: () => onChange(index),
              child: Padding(
                padding: const EdgeInsets.symmetric(
                  horizontal: 10,
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text("${_controller.menus[index].value}",
                        style: TextStyle(
                          fontSize: index == currentIndex ? 18 : 13,
                          fontWeight: index == currentIndex
                              ? FontWeight.w700
                              : FontWeight.w500,
                        )),
                    if (currentIndex == index)
                      Container(
                        width: 24,
                        height: 4,
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(20),
                          color: Colors.black,
                        ),
                      ),
                  ],
                ),
              ),
            ),
          ),
        ),
      );
}
